﻿using Super_Management_Mayhem.Content.Animations.Manager;
using System;
using Transformable_Engine_v2.Engine.Animation.FrameAnimation;
using Transformable_Engine_v2.Engine.Time;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Super_Management_Mayhem.Screens.Playing.Players.Manager
{
    public partial class Manager
    {
        private Timer _pickupTimer;

        private void InitializePickupStateObjects()
        {
            _pickupTimer = new Timer(1, false, EndPickup);
            AddTimers(_pickupTimer);
        }

        private void EndPickup()
        {
            _pickUpItemLayer.PositionGridBound = new TE_Vector2(0, -1.5f);
            ChangeState(PlayerState.Idle);
        }

        private void HandleKeyPressPickupState(Input input) {}

        private void HandleKeyReleasePickupState(Input input) {}

        private void InitializePickupState()
        {
            _isCarrying = true;
            switch (_latestDirection)
            {
                case Direction.Up:
                    _character.AddAnimations(new FrameAnimation(new PickupUp(SpriteSheetPath)));
                    _character.OriginAbsolute = new TE_Vector2(12, 31);
                    _pickupTimer.Reset(PickupUp.AnimationTime);
                    _pickUpItemLayer.PositionGridBound = new TE_Vector2(0, -0.75f);
                    break;
                case Direction.Down:
                    _character.AddAnimations(new FrameAnimation(new PickupDown(SpriteSheetPath)));
                    _character.OriginAbsolute = new TE_Vector2(12, 31);
                    _pickupTimer.Reset(PickupDown.AnimationTime);
                    _pickUpItemLayer.PositionGridBound = new TE_Vector2(0, 0.5f);
                    break;
                case Direction.Left:
                    _character.AddAnimations(new FrameAnimation(new PickupLeft(SpriteSheetPath)));
                    _character.OriginAbsolute = new TE_Vector2(12, 31);
                    _pickupTimer.Reset(PickupLeft.AnimationTime);
                    _pickUpItemLayer.PositionGridBound = new TE_Vector2(-1, 0);
                    break;
                case Direction.Right:
                    _character.AddAnimations(new FrameAnimation(new PickupRight(SpriteSheetPath)));
                    _character.OriginAbsolute = new TE_Vector2(12, 31);
                    _pickupTimer.Reset(PickupRight.AnimationTime);
                    _pickUpItemLayer.PositionGridBound = new TE_Vector2(1, 0);
                    break;
            }

        }

        private void UpdatePickupState(TimeSpan gameTime) {}
    }
}
